<?php
// 读取数据库
$pdo = new PDO('mysql:host=localhost;port=3306;dbn=mydata', 'root', '123456');

$stmt = $pdo->query('select * from mydata');

while ($row = $stmt->fetch()) {

    // do something with result

}